import { v4 as uuid4 } from 'uuid';
/**
 * @desc 转化canvasmarkers数据
 * @param {*} data
 * @returns
 */
export const transData = (data) => {
  let returnData = [];
  if (data && Array.isArray(data) && data.length) {
    let returnItem = null;
    data.map((item) => {
      returnItem = {
        positions: item.positions,
        id: item.id || uuid4(),
        overlayType: 'CanvasMarker',
        style: {
          radius: 20000,
          color: item.color || '#6bffff',
          iconUrl: '/images/LeafletImages/1.jpg',
        },
        label: item.name,
        // 标注样式
        labelStyle: {
          color: item.color || '#6bffff',
          fontSize: '14px',
          fontWeight: 'bold',
        },
        payload: {
          ...item,
        },
      };
      returnData.push(returnItem);
    });
  }
  return returnData;
};
